package mapper.UserManagement;

import entity.UserInfForStu;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import entity.User;

import java.util.LinkedHashMap;
import java.util.List;

//import省略
@Repository
public interface UserMapper {
	@Update("update User set icon=#{icon} where userId=#{userId}")
	public int updateUserIcon(@Param("icon")String icon,@Param("userId") String userId);

    @Select("select * from User where userId=#{userId} and passWord=#{passWord} ")
    public User findUser(User user);

	@Insert("insert into User(userId,name,type,passWord,icon) values(#{userId},#{name},#{type},#{passWord},#{icon})")
	public int addUser(User user);

	@Update("update User set userInformationId = #{userInformationId} where userId = #{userId};")
	public int addUserInformationId(@Param("userInformationId") String userInformationId, @Param("userId") String userId);

    @Select("select UserInfForStu.* from UserInfForStu where phoneNumber=#{phoneNumber}")
    public UserInfForStu showUser(@Param("phoneNumber")String phoneNumber);

    @Select("select UserInfForEn.*,Enterprise.name AS enterpriseName from UserInfForEn,Enterprise where UserInfForEn.enterpriseId = Enterprise.enterpriseId AND UserInfForEn.phoneNumber = #{phoneNumber}")
    public LinkedHashMap<String,Object> showEnr(@Param("phoneNumber")String phoneNumber);


//	@Delete("delete from users where id=#{id}")
//	public int deleteUser(int id);
//
//
//
//	@Select("select * from User where id=#{userId}")
//	public User getUserById(int id);
//


	@Select("select * from User where userId=#{userId}")
	public User findUserByUserId(String userId);
//
//	@Select("select * from users")
//	public List<User> getAllUsers();
}